﻿using System.Web;

namespace Ndex.Core.Web
{
    public class SessionManager
    {
        public static T Get<T>(string key)
        {
            if (Exist(key))
                return (T)HttpContext.Current.Session[key];
            return default(T);
        }

        public static void Set<T>(string key, T val)
        {
            HttpContext.Current.Session[key] = val;
        }

        public static void Clear(string key)
        {
            
            HttpContext.Current.Session.Remove(key);
        }

        public static void Clear()
        {
            HttpContext.Current.Session.Clear();
        }

        public static bool Exist(string key)
        {
            return HttpContext.Current.Session[key] != null;
        }
    }
}
